/**
 * Desenvolvido pela Fábrica de Software do CESUPA.
 * Todos os direitos reservados.
 */
package br.cesupa.fabsoft.nomedoprojeto.system.application.facades;

import javax.faces.context.FacesContext;

/**
 * Utilities to manipulate the beans instances managed by the Java Server Faces
 * framework.
 *
 * @author Breno Leite
 */
public class ManagedBeanFacade {

    /**
     * @param beanName the named of the bean as defined in the 
     * <code>faces-config.xml</code> file
     * 
     * @return the instance of the bean been managed by the Java Server Faces
     */
    public Object getManagedBeanCurrentInstance(final String beanName) {
        FacesContext currentContext = FacesContext.getCurrentInstance();
        Object object = currentContext.getELContext().getELResolver().getValue(
                currentContext.getELContext(), null, beanName);
        return object;
    }
}
